/**
 * Exam.java.
 */
package rs.edu.fit.model;

public class Exam {
	/** Name of the exam. */
	private String name;
	/** Tag of the exam. */
	private String tag;
	/** Years of the study on witch exam is lectured. */
	private int yearOfStudy;
	/** Assistent that supervised exam. */
	private Assistent assistent;

	/** Default constructor, can not be instantilized. */
	@SuppressWarnings("unused")
	private Exam() {
		
	}

	/**
	 * Working constructor; without Assistent.
	 * 
	 * @param name
	 *            of the exam.
	 * @param tag
	 *            of the exam.
	 * @param yearOfStudy
	 *            on witch exam is lectured.
	 */
	public Exam(String name, String tag, int yearOfStudy) {
		super();
		this.name = name;
		this.tag = tag;
		this.yearOfStudy = yearOfStudy;
	}

	/**
	 * Working constructor with all data.
	 * 
	 * @param name
	 *            of the exam.
	 * @param tag
	 *            of the exam.
	 * @param yearOfStudy
	 *            on witch exam is lectured.
	 * @param assistent
	 *            that supervised exam.
	 */
	public Exam(final String name, final String tag, 
			final int yearOfStudy, final Assistent assistent) {
		super();
		this.name = name;
		this.tag = tag;
		this.yearOfStudy = yearOfStudy;
		this.assistent = assistent;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(final Object o) {
		if (o instanceof Exam) {
			Exam exam = (Exam) o;
			return this.tag.equals(exam.getTag());
		} 
		return false;
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		int result = 37;
		result += tag.hashCode() * 27;
		
		return result;
	}

	/* Only getters, setters and toString from this point. */
	
	public final String getName() {
		return name;
	}

	public final void setName(String name) {
		this.name = name;
	}

	public final String getTag() {
		return tag;
	}

	public final void setTag(String tag) {
		this.tag = tag;
	}

	public final int getYearOfStudy() {
		return yearOfStudy;
	}

	public final void setYearOfStudy(int yearOfStudy) {
		this.yearOfStudy = yearOfStudy;
	}

	public final Assistent getAssistent() {
		return assistent;
	}

	public final void setAssistent(Assistent assistent) {
		this.assistent = assistent;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Exam [name=" + name + ", tag=" + tag + ", yearOfStudy="
				+ yearOfStudy + ", assistent=" + assistent + "]";
	}
}
